package com.graduate.game.topic.service;
import com.graduate.game.topic.mapper.topicMapper;
import com.graduate.game.topic.pojo.comment;
import com.graduate.game.topic.pojo.topic;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class TopicServiceImpl implements TopicService {
    //@Resource按名字自动注入
    @Resource
    private topicMapper topicmapper;

    @Override
    public List<topic> lookAll() {
        return topicmapper.getAllTopic();
    }

    @Override
    public topic getrandomOneger() {
        return topicmapper.getOneTopic();
    }

    @Override
    public topic getIDone(int themeid) {
        return topicmapper.getIdContent(themeid);
    }

    @Override
    public boolean insertTopic(topic topic) {
        int x = topicmapper.insertTopic(topic);
        if(x>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public List<topic> getOneUser(String publisher) {
        return topicmapper.getOneUsername(publisher);
    }

    @Override
    public List<topic> serchtopic(String title) {
        return topicmapper.serchtopic(title);
    }

    @Override
    public int addTopicnum(topic topic) {
        System.out.println("进入service");
        topicmapper.addAnnenadedAn(topic);
        return 1;
    }

    @Override
    public int checkAnnext(int themeid) {
        int checkannext = topicmapper.checkannext(themeid);
        return checkannext;
    }

    @Override
    public List<topic> findAllBypage(Map<String, Object> data) {
        List<topic> allTopicBypage = topicmapper.getAllTopicBypage(data);
        return allTopicBypage;
    }

    @Override
    public boolean insertComment(comment comment) {
        int x = topicmapper.insertComment(comment);
        if(x>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public List<comment> getallcommnets(int themeid) {
        return topicmapper.getAllComment(themeid);
    }

    @Override
    public boolean delById(long id) {
        int x = topicmapper.delById(id);
        if(x>0){
            return true;
        }else {
            return false;
        }
    }

}
